/* Stats on Consumption Categories 
	Created: 11/29/18
	*/
	
clear
set more off
cd "$path_name"
do Define_Extensions.do
second_stage_dataset
	
	foreach yr in 1980 1990 2000 2010{
		// Summary Stats
		qui tabstat $variablesr if year==`yr', ///
		statistics(mean sd p5 p10 p25 p75 p90 p95 N) ///
		columns(statistics) save
		matrix define Stats`yr' = r(StatTotal)
		
		// Get Zerocounts
		matrix define Zero`yr' = J(1, 20, .)
		local i = 1
		foreach var in $variablesr{
			qui count if `var' == 0 & year==`yr'
			matrix Zero`yr'[1,`i'] = r(N)
			local i = `i'+1
		}
		matrix rownames Zero`yr'= "zeros"
		
		// Concatenate matrices together
		matrix Stats`yr' = Stats`yr'\Zero`yr'
		// Transpose
		matrix Stats`yr' = Stats`yr''
	}
	
	


	putexcel set "CatSum", replace
	putexcel A1 = 1980
	putexcel A2 = matrix(Stats1980), names
	putexcel A23 = 1990
	putexcel A24 = matrix(Stats1990), names
	putexcel A45 = 2000
	putexcel A46 = matrix(Stats2000), names
	putexcel A67 = 2010
	putexcel A68 = matrix(Stats2010), names
	
	/*
	foreach yr in 1980 1990 2000 2010{
		foreach var in $variablesr{
			eststo: su `var' if year ==`yr', detail
		}
	}
	
	/*
	foreach var in $variablesr{
		rename `var' cons`var
	}

	reshape long cons, i(id) j(goods) str
